﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MvcApplication2.Helpers
{
    public interface ISessionHelper
    {
        T Get<T>(string key);
        void Set<T>(string key, T value);
        void Remove<T>(string key);
    }

    public class SessionHelper : ISessionHelper
    {
        public T Get<T>(string key)
        {
            var value = HttpContext.Current.Session[key];

            return value == null ? default(T) : (T) value;
        }

        public void Set<T>(string key, T value)
        {
            HttpContext.Current.Session[key] = value;
        }

        public void Remove<T>(string key)
        {
            HttpContext.Current.Session.Remove(key);
        }
    }
}